#ifndef UTI_STATISTICS_H_
#define UTI_STATISTICS_H_
#pragma once
#include "sys_config.h"
#include "uti_ordersysmapseries.h"

#include "KompexSQLitePrerequisites.h"
#include "KompexSQLiteDatabase.h"
#include "KompexSQLiteStatement.h"
#include "KompexSQLiteException.h"
#include "KompexSQLiteStreamRedirection.h"
#include "KompexSQLiteBlob.h"

#include <iostream>
#include <exception>
using namespace Kompex;


class CStatistics
{
public:


	CStatistics(string& strategy_id, map<string, OrderSysMapSeries*>&maptrademan);

	~CStatistics();

	bool WriteData();

private:


	bool InitDBInfo(string& strategy_id);

	void DestroyDBInfo();

	bool InitBuffer();

	void DestroyBuffer();



	bool OpenDB();

	bool WriteDB();

	bool CloseDB();


	bool InsertDB(unsigned int index);


private:

	typedef struct DBINFO
	{
		DBINFO(string& _dbname)
		{
			pdb = NULL;
			pst = NULL;

			dbname = _dbname;		
		};


		string dbname;
		vector<string> tbname;


		SQLiteDatabase* pdb;
		SQLiteStatement* pst;


	}DBINFO;

	DBINFO* m_pdbinfo;

	char* m_buffer;

	map<string, OrderSysMapSeries*>& m_maptrademan;

	const string m_dbname_sufix;

	const string m_tablename;


	


};

#endif